<?php

class Test_Active_Record_model extends CI_Model {

	function __construct()
	{
		parent::__construct();
	}

	function test_get($tbl = 'test')
	{
		return $this->db->get($tbl)->result();   	
	}   

	function test_get_limit($tbl = 'test')
	{
		return $this->db->get($tbl,1,2)->result();   	
	}   

	function test_get_where($tbl = 'test', $id = 2)
	{
		return $this->db->get_where($tbl, array('id' => $id))->result();   	
	}
	
	function test_select($tbl = 'test')
	{
		return $this->db->select('id', 'name')->get($tbl)->result();   	
	}
	
	function test_select_max($tbl = 'test', $fld = 'id')
	{
		return $this->db->select_max($fld, 'max_of_' . $fld)->get($tbl)->result();   	
	}

	function test_select_min($tbl = 'test', $fld = 'id')
	{
		return $this->db->select_min($fld, 'min_of_' . $fld)->get($tbl)->result();   	
	}   

	function test_select_avg($tbl = 'test', $fld = 'id')
	{
		return $this->db->select_avg($fld, 'avg_of_' . $fld)->get($tbl)->result();   	
	}   

	function test_select_sum($tbl = 'test', $fld = 'id')
	{
		return $this->db->select_sum($fld, 'sum_of_' . $fld)->get($tbl)->result();   	
	}

	function test_insert($tbl = 'test', $data = array('name' => 'testing123'))
	{
		return $this->db->insert($tbl, $data);   	
	}  

	function test_update($tbl = 'test', $fld = 'id', $val = 1, $data = array('name' => 'updated name'))
	{
		return $this->db->where($fld, $val)->update($tbl, $data);   	
	}  

	function test_delete($tbl = 'test', $fld = 'name', $val = "testing123")
	{
		return $this->db->where($fld, $val)->delete($tbl);   	
	}  


}